

<%@page import = "clothing.database.EmployeeManager" %>

<%@page import = "clothing.database.MValidation" %>

<%@ page import = "clothing.database.CustomerManager" %>
<%@ page import = "clothing.database.Customer" %>
<%@ page import = "java.util.ArrayList" %>

<%@ include file = "templates/header.jsp" %>

<h3> Customer Page </h3>
<script>
function process(a)
{
	var con = confirm("Are you sure you want to delete this customer? ");
	if(con==true)
	{
		document.getElementById('id').value=a;
		document.myform.submit();
	}
} 
function process2 (a)
{
	document.getElementById('id2').value=a;
	document.myform2.submit();		
}
</script>
		
<%@ include file="templates/main_nav.jsp" %>


<% 
	CustomerManager cm = new CustomerManager();
	ArrayList<Customer> list = cm.getList();
	
	out.println("<form name =\"myform\" id=\"myform\" action =\"deleteCustomer.jsp\" method=\"post\">");
	out.println("<table>");
	%>
	<tr>
		<td><strong>Customer ID</strong></td>
		<td><strong>First Name</strong></td>
		<td><strong>Last Name</strong></td>
		<td><strong>Street</strong></td>
	    <td><strong>City</strong></td>
        <td><strong>State</strong></td>	
        <td><strong>Zip</strong></td>	
        <td><strong>Email</strong></td>		


	
	</tr>
	
	<input type="hidden" name ="id" id = "id" />
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		out.println("<tr>");
		Customer current = list.get(i);
		    out.println("<td>"+ current.getCustomerId()+"</td>");
			out.println("<td>"+ current.getFirstName()+"</td>");
			out.println("<td>"+ current.getLastName()+"</td>");
			out.println("<td>"+ current.getStreet()+"</td>");
			out.println("<td>"+ current.getCity()+"</td>");
			out.println("<td>"+ current.getState()+"</td>");
			out.println("<td>"+ current.getZip()+"</td>");
			out.println("<td>"+ current.getEmail()+"</td>");
		
			%>
			<td><input type="button" value ="Delete" onclick = "process(<%=current.getCustomerId() %>);" /></td>
			<td><input type="button" value ="Edit" onclick = "process2(<%=current.getCustomerId() %>);" /></td>
			<% 
		out.println("</tr>");
	}
	

	out.println("</table></form>");
	
	
%>

<form name="myform2" id="myform2" action="editCustomer.jsp" method="post">
<input type="hidden" name="id2" id="id2" />
</form>

<h2> Add a Customer </h2>
<form action ="addCustomer.jsp" method = "post" >
	<table>
		<tr>
			<td>First Name: </td><td><input type="text" name="firstname" /></td>
		</tr>

		<tr>
			<td>Last Name: </td><td><input type="text" name="lastname" /></td>
		</tr>

		
        <tr>
			<td>Street: </td><td><input type="text" name="street" /></td>
		</tr>

        <tr>
			<td>City: </td><td><input type="text" name="city" /></td>
		</tr>

         <tr>
         	<td> State: </td>
         	<td>
			<select name="state" size="1">
	<option value="AK">AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select>
</td>
		</tr>

         <tr>
			<td>Zip: </td><td><input type="text" name="zip" /></td>
		</tr>

        <tr>
			<td>Email: </td><td><input type="text" name="email" /></td>
		</tr>




		
		<tr>
			<td> </td><td><input type="submit" value= "submit" /></td>
		</tr>
	</table>
	</form>

<%@ include file = "templates/footer.jsp" %>
